package org.wmine.core;

import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import javax.swing.JTextField;

import org.wmine.preprocess.Discretization;

import java.awt.Toolkit;

public class IntegerTextField extends JTextField
{
	final static String badchars="{}[]`~!@#$%^*()_+-=\\|\",;.?:/><&";
	private static final Discretization FocusListener = null;
	
	public void processKeyEvent(KeyEvent ev)
	{
		char c=ev.getKeyChar();
		if((Character.isLetter(c) && !ev.isAltDown()) || badchars.indexOf(c) > -1)
		{
			ev.consume();
			Toolkit.getDefaultToolkit().beep();
			return;
		}
		if(c=='-' && getDocument().getLength() > 0)
		{
			ev.consume();
			Toolkit.getDefaultToolkit().beep();
		}
		else
			super.processKeyEvent(ev);
	}

	
	
}
